import React from 'react';
import './index.less';
import {bindAction, bindModel, render} from 'react-division';
import FormModel from './models/ModelInfo';
import FormAction from './actions/ModelInfo';
import formCreate from 'lib/ConfigForm';
import InfoMain from './actions/InfoMain';
import {Button, Space} from 'antd';

bindAction({
    modelInfoA: FormAction,
    infoMainA: InfoMain
});
bindModel({
    modelInfoM: FormModel
});


const ConfigForm = formCreate({
    modelName: 'modelInfoM',
    actionName: 'modelInfoA'
});


export default render({
    models: ['modelInfoM'],
    actions: ['modelInfoA', 'infoMainA']
})(class extends React.Component {
    constructor(props) {
        super(props);
    }

    render() {
        const {action} = this.props;
        const {infoMainA} = action;

        return (
            <div className="model-info-page">
                <ConfigForm />
                <div className="model-info-footer">
                    <Space>
                        <Button
                            onClick={infoMainA.saveModelInfo}
                            type="primary"
                        >
                            保存
                        </Button>
                        <Button
                            onClick={infoMainA.cancelModelInfo}
                        >
                            取消
                        </Button>
                    </Space>
                </div>
            </div>
        );
    }
});